package com.badibadi.mail;

import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.layout;
import com.badibadi.uniclubber.R.menu;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
/**
 * 问方：付款成功，等待答方回复
 * 答方：点击回复后进入回复主页 (Mail15_huifuActivity)
 * 答方回答问方的问题
 * 
 * @author Administrator
 *
 */
public class Mail8_14_15Activity extends Mail245Activity {
	AlertDialog al;
	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case 1:
				Utils.ExitPrgress(Mail8_14_15Activity.this);
				try {
					Utils.showMessage(Mail8_14_15Activity.this, getResources().getString(R.string.l_net_error));
				} catch (Exception e) {
					// TODO: handle exception
					// throw new NullPointerException("getActivity() is Null");
				}

				break;
			case 2:
				Utils.ExitPrgress(Mail8_14_15Activity.this);

				try {
//					jump();
					LayoutInflater inflater=LayoutInflater.from(Mail8_14_15Activity.this);
		            View view=inflater.inflate(R.layout.duifangfukuanchenggong, null);
                 //退款工作日
		            TextView refund_time=(TextView)view.findViewById(R.id.refund_time);
		            refund_time.setText(""+payUserContactShow1Model.getRefund_time());
		            //退款间隔时间
		          TextView replay_limit_time=(TextView)view.findViewById(R.id.replay_limit_time);
		          replay_limit_time.setText(""+payUserContactShow1Model.getReplay_limit_time());
		            
		            
					view.findViewById(R.id.queding).setOnClickListener(new View.OnClickListener() {
						
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							al.dismiss();
						}
					});
					
					al=new AlertDialog.Builder(Mail8_14_15Activity.this).setView(view).show();
				} catch (Exception e) {
					// TODO: handle exception
				}
				break;
		

			default:
				break;
			}
		}
	};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_mail8_14_15);
		
	}

	@Override
	protected void DongTaiPeiZhi() {
		// TODO Auto-generated method stub
		if(rank.equals("answerer"))//答方
		{
			TextView t=(TextView)this.findViewById(R.id.tishi);
			t.setText(getResources().getString(R.string.wx_fukuan_success_kuohao));
			t.setVisibility(View.VISIBLE);
			new Thread(new Runnable() {
				
				@Override
				public void run() {
					// TODO Auto-generated method stub
					try {
						Thread.sleep(500);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						   
					}
					mHandler.sendEmptyMessage(2);
				}
			}).start();
			
			
			Button huifu=(Button)this.findViewById(R.id.shedingzhixunfei);
			huifu.setVisibility(View.VISIBLE);
			huifu.setText(getResources().getString(R.string.wx_reply));
			//回复
			huifu.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
				   	Intent intent=new Intent(Mail8_14_15Activity.this,Mail15_huifuActivity.class);
				   	intent.putExtra("payUserContactShow1Model", payUserContactShow1Model);
			
				   	startActivity(intent);
				   	finish();
				}
			});
			
			
			
			
			
			
		}else//问方
		{
			Button shedingzhixunfei=(Button)this.findViewById(R.id.shedingzhixunfei);
			shedingzhixunfei.setVisibility(View.VISIBLE);
			shedingzhixunfei.setText(getResources().getString(R.string.wx_chakan_zhixunfei));
			shedingzhixunfei.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
//					Toast.makeText(Mail8_14_15Activity.this, "付款成功", Toast.LENGTH_SHORT);
					Toast toast=Toast.makeText(getApplicationContext(), getResources().getString(R.string.wx_fukuan_success), Toast.LENGTH_SHORT);  
			        //第一个参数：设置toast在屏幕中显示的位置。
			        //第二个参数：相对于第一个参数设置toast位置的横向X轴的偏移量，正数向右偏移，负数向左偏移  
			        //第三个参数：同的第二个参数道理一样  
			        //如果你设置的偏移量超过了屏幕的范围，toast将在屏幕内靠近超出的那个边界显示  
			        toast.setGravity(Gravity.CENTER, 0, 0);
			        //屏幕居中显示，X轴和Y轴偏移量都是0  
			        //toast.setGravity(Gravity.CENTER, 0, 0);   
			        toast.show();  
				}
			});
		}
	}
	

}
